package com.rede.didiok.user.modulelist.rank.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.rede.didiok.common.utils.PageUtils;
import com.rede.didiok.common.utils.R;
import com.rede.didiok.user.modulelist.rank.entity.ReasonEntity;
import com.rede.didiok.user.modulelist.rank.service.ReasonService;


/**
 * 榜单成员的上榜理由
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-07-20 22:09:24
 */
@RestController
@RequestMapping("rank/reason")
public class ReasonController {
    @Autowired
    private ReasonService reasonService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("rank:reason:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = reasonService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{reasonId}")
    // @RequiresPermissions("rank:reason:info")
    public R info(@PathVariable("reasonId") Long reasonId){
		ReasonEntity reason = reasonService.getById(reasonId);

        return R.ok().put("reason", reason);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("rank:reason:save")
    public R save(@RequestBody ReasonEntity reason){
		reasonService.save(reason);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("rank:reason:update")
    public R update(@RequestBody ReasonEntity reason){
		reasonService.updateById(reason);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("rank:reason:delete")
    public R delete(@RequestBody Long[] reasonIds){
		reasonService.removeByIds(Arrays.asList(reasonIds));

        return R.ok();
    }

}
